package com.camps.sdk.decrypt;

import com.camps.sdk.common.Constants;
import com.camps.sdk.entity.DeviceUpMessage;
import com.camps.sdk.entity.PowerOnMessage;

/**
 * @Author ldaoliang
 * @Date create in 15:58 2021/9/1
 * @Description
 */
public class AnalyzePowerOn implements AnalyticalData {
    @Override
    public DeviceUpMessage parseData(String originalData) {
        // *WT,800115470000876,POWERON,170122,m1,595,MFD03_CTA_001,V,ALOE01002708,ALOE01002708,13912345678,FFFFDFFF#
        //解密
        String[] split = parseCommand(originalData);
        String imei = split[1];
        String commandNumber = split[3];
        String mode = split[4].substring(1);//当前工作模式
        String interval = split[5];//当前上报间隔
        String deviceStatus = split[11];
        String firmware = split[6];
        String m1Card = split[9];
        String uId = split[8];
        String phone = split[10];
        PowerOnMessage powerOnMessage = new PowerOnMessage();
        powerOnMessage.setAnswerVersion(uId);
        powerOnMessage.setM1Card(m1Card);
        powerOnMessage.setCommandNumber(commandNumber);
        powerOnMessage.setFirmware(firmware);
        powerOnMessage.setImei(imei);
        powerOnMessage.setuId(uId);
        powerOnMessage.setPhone(phone);
        powerOnMessage.setDeviceStatus(deviceStatus);
        powerOnMessage.setMode(Integer.parseInt(mode));
        powerOnMessage.setInterval(Integer.parseInt(interval));
        String str="*WT,".concat(imei).concat(",WEATHER,").concat(commandNumber).concat(",2,19,1,0#");
        return structureMessage(Constants.UPLOAD,Constants.UP_POWER_ON,true,str,powerOnMessage);
    }
}
